package com.hmall.util;

import com.hmall.vo.MallHotVo;
import com.hmall.model.MallProduct;

import java.math.BigDecimal;

public class CastHotUtil {


    public static  MallHotVo hotCast(MallProduct mallProduct, BigDecimal salesVolume, String grade){

        MallHotVo mallHotVo = new MallHotVo();
        mallHotVo.setSales_volume(salesVolume);
        mallHotVo.setCategoryId(mallProduct.getCategoryId());
        mallHotVo.setCommentNum(mallProduct.getCommentNum());
        mallHotVo.setContent(mallProduct.getContent());
        mallHotVo.setCreateTime(mallProduct.getCreateTime());
        mallHotVo.setDetail(mallProduct.getDetail());
        mallHotVo.setId(mallProduct.getId());
        mallHotVo.setIsnew(mallProduct.getIsnew());
        mallHotVo.setMainImage(mallProduct.getMainImage());


        mallHotVo.setGrade(grade);
        String str[] = mallProduct.getName().split(",", -1);
        //暂时写死，要改逻辑业务
        mallHotVo.setTypeName(str[0]);
        String subName = "";
        int flag = 0;
        for(String subStr : str){
            flag++;
            if(flag <= 1) {
                continue;
            }
            if(flag == 2) {
                subName += subStr;
            } else {
                subName += "," + subStr;
            }
        }
        mallHotVo.setName(subName);

        mallHotVo.setDetailName(mallProduct.getName());

        mallHotVo.setPrice(mallProduct.getPrice());
        mallHotVo.setProductno(mallProduct.getProductno());
        mallHotVo.setSearchHot(mallProduct.getSearchHot());
        mallHotVo.setSpecial(mallProduct.getSpecial());
        mallHotVo.setStatus(mallProduct.getStatus());
        mallHotVo.setSubImages(mallProduct.getSubImages());
        mallHotVo.setSubtitle(mallProduct.getSubtitle());
        mallHotVo.setShopid(mallProduct.getShopid());
        mallHotVo.setStock(mallProduct.getStock());
        mallHotVo.setUpdateTime(mallProduct.getUpdateTime());
        mallHotVo.setUprice(mallProduct.getUprice());
        return mallHotVo;
    }
}
